﻿@if (false) {<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.min.js" type="text/javascript" />}
@{string list = "list15", pager = "pager15", entity = "FinishedOutDepository";}
<table id="@list" class="scroll" cellpadding="0" cellspacing="0">
</table>
<div id="@pager" class="scroll" style="text-align: center;">
</div>
<script type="text/javascript">
    jQuery(function () {
        $("#@list").jqGrid({
            url: "/@entity/index/",
            colNames: ["排产单号", "产品编号", "产品名称", "型号", "单位", "出库日期", "出库数量", "批次号", "备注"],
            colModel: [
            $.jgridx.strNullCol("ProduceNumber"),
            $.jgridx.strAuto1Col("ProductValueObject.Number", "/FinishedOutDepository/get"),
            { name: 'ProductValueObject.Name', index: 'ProductValueObject.Name', width: 80, search: false },
            { name: 'ProductValueObject.Model', index: 'ProductValueObject.Model', width: 80, search: false },
            { name: 'ProductValueObject.Unit', index: 'ProductValueObject.Unit', width: 80, search: false },
            $.jgridx.dateCol("Date"),
            $.jgridx.intCol("RealCount"),
            $.extend($.jgridx.strAutoCol("Number", "/FinishedOutDepository/AutoComNumber"),
            {
                editrules:
            {
                required: false
            },
                formoptions:
            {
                elmsuffix: "（自动填写）"
            }
            }),
            {
                name: "Remark",
                index: "Remark",
                width: 200,
                editable: true,
                edittype: "textarea",
                search: false
            }
            ],
        //multiselect: false,
        pager: $('#@pager'),
        sortname: "OutDepositoryId",

        footerrow: true,
        userDataOnFooter: true,

        loadComplete: function (data) {

            if (!data.success)
                $(this).jqGrid("clearGridData", true);
        }
    });
    $("#@list").jqGrid('navGrid', '#@pager',
        {
            edit: false,
            add: true,
            search: true,
            del: false,
            refresh: true
        },
        {
            url: "/@entity/edit/"
        },
        {
            url: "/@entity/add/",
            onClose: function () {
                $("#temptr").remove();
            }
        },
        {
            url: "/@entity/delete/"
        }, {}, {}).navSeparatorAdd("@pager", { sepclass: "ui-separator", sepcontent: '' })
        .jqGrid('navButtonAdd', "@pager", { caption: "",
            buttonicon: "ui-icon ui-icon-print",
            position: "last",
            title: "成品出库单",
            onClickButton: function () {
                var rowids = $("#@list").jqGrid('getGridParam', 'selarrrow');
                if (rowids.length == 0) {
                    Alert("警告", "请选择记录！");
                    return;
                }
                var title = "成品出库单"
                var p = $("#@list");
                var h = p.parent().parent().parent().find("table").eq(0).find("thead");
                var printhtml = []
                printhtml.push(h.html());
                $.each(p.find("tr"), function (index, value) {
                    if (inarray(rowids, $(this).attr("id"))) {
                        printhtml.push("<tr>" + $(this).html() + "</tr>");
                    }
                });

                var printdiv = $('<div id="printdiv"><h1>' + title + '</h1><table cellspacing="0" cellpadding="0" border="0">' + printhtml.join('') + '</table></div>');
                $.each(printdiv.find("tr"), function () {
                    $(this).children().eq(0).remove();
                });
                printdiv.find("span").remove();
                Print(printdiv);

            }
        })
        .jqGrid('navButtonAdd', "@pager", { caption: "",
            buttonicon: "ui-icon ui-icon-disk",
            position: "last",
            title: "导出",
            onClickButton: function () {
                if ($("#@(list)excel").length == 0) {
                    $(this).after('<form id="@(list)excel" method="post" action="/@entity/Report.xls"></form>');
                }
                $("#@(list)excel").submit()
                //$.ajax("/PartsInDepository/Report");
            }
        })
        ;
});
</script>